package mobi.hami.huapin.dao;

import mobi.hami.huapin.model.UserInvoice;

import java.util.List;
import java.util.Map;

public class UserInvoiceProvider {

    public  String selectUserInvoiceWitchParam(Map<String,Object> parms){
        StringBuilder sb = new StringBuilder();
        sb.append("select * from user_invoice where ");
        if(null != parms && !parms.isEmpty()){
            if(null != parms.get("user_id") && !parms.get("user_id").equals("")){
                sb.append("user_id = ").append(parms.get("user_id")).append(" and ");
            }
            if(null != parms.get("open_id") && !parms.get("open_id").equals("")){
                sb.append("open_id = '").append(String.valueOf(parms.get("open_id"))).append("'").append(" and ");
            }
            if(null != parms.get("order_id") && !parms.get("order_id").equals("")){
                sb.append("order_id = ").append(parms.get("order_id")).append(" and ");
            }
            if(null != parms.get("type") && !parms.get("type").equals("")){
                sb.append("type = ").append(parms.get("type")).append(" and ");
            }
            if(null != parms.get("ein") && !parms.get("ein").equals("")){
                sb.append("ein = '").append(String.valueOf(parms.get("ein"))).append("'").append(" and ");
            }
            if(null != parms.get("content") && !parms.get("content").equals("")){
                sb.append("content = '").append(String.valueOf(parms.get("content"))).append("'").append(" and ");
            }
            if(null != parms.get("contact_name") && !parms.get("contact_name").equals("")){
                sb.append("contact_name = '").append(String.valueOf(parms.get("contact_name"))).append("'").append(" and ");
            }
            if(null != parms.get("contact_mobile") && !parms.get("contact_mobile").equals("")){
                sb.append("contact_mobile = '").append(String.valueOf(parms.get("contact_mobile"))).append("'").append(" and ");
            }
            if(null != parms.get("contact_address") && !parms.get("contact_address").equals("")){
                sb.append("contact_address = '").append(String.valueOf(parms.get("contact_address"))).append("'").append(" and ");
            }
        }
        sb.append("1 = 1 ");
        sb.append("order by create_time desc");
        System.out.println(sb.toString());
        return sb.toString();
    }

}
